package com.zhss.redis.hyperloglog;


import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Optional;

/**
 * 垃圾数据过滤演示
 *
 * @author winston
 * @date 2021/11/04
 */
public class JunkDataFilterDemo {
	HostAndPort hostAndPort = new HostAndPort("121.4.79.149", 6379);
	Jedis jedis = new Jedis(hostAndPort);
	private String key = "hyperloglog_content";

	public boolean isJunkData(String content) {
		return jedis.pfadd(key, content) == 0;
	}

	public static void main(String[] args) {
//		JunkDataFilterDemo filterDemo = new JunkDataFilterDemo();
//
//		System.out.println(filterDemo.isJunkData("我是垃圾了吗?"));
//		System.out.println(filterDemo.isJunkData("我是垃圾了吗?"));

		List<Integer> list = List.of(1, 2, 1, 2, 3, 4, 5, 6, 3, 4, 5);
		Optional<Integer> reduce = list.stream().reduce((i, j) -> i ^ j);
		System.out.println(reduce.get());
	}

	public void merge() {
//		jedis.pfmerge()
	}
}
